﻿using FileUtility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Data;
using FileMonitor.Configuration;
using System.Collections.Generic;
using System.Collections.Specialized;
using FileMonitor.Configuration.Tool;

namespace TestProject
{
    
    
    /// <summary>
    ///This is a test class for UtilityDataControllerTest and is intended
    ///to contain all UtilityDataControllerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class UtilityDataControllerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ReadFileContentToDataTable
        ///</summary>
        //[TestMethod()]
        public void ReadFileContentToDataTableTest()
        {
            string filePath = @"D:\SICT\Files\RFXCZ00D_20100530.txt"; // TODO: Initialize to an appropriate value
            DataTable dtTarget = new DataTable() ; // TODO: Initialize to an appropriate value
            dtTarget.Columns.Add("BatchID", typeof(string));
            dtTarget.Columns.Add("Indicator", typeof(string));
            dtTarget.Columns.Add("PlantCode", typeof(string));
            dtTarget.Columns.Add("PlanCreateDT", typeof(string));
            dtTarget.Columns.Add("ProdLineCD", typeof(string));
            dtTarget.Columns.Add("PartNo", typeof(string));
            dtTarget.Columns.Add("Region", typeof(string));
            dtTarget.Columns.Add("Location", typeof(string));
            dtTarget.Columns.Add("DueDate", typeof(string));
            dtTarget.Columns.Add("RefenceDate", typeof(string));
            dtTarget.Columns.Add("CreateDate", typeof(string));



            Guid batchId =   Guid.NewGuid(); // TODO: Initialize to an appropriate value
            int[] columnLengthArr = {36,1,4,8,2,16,4,4,12,8,8}; // TODO: Initialize to an appropriate value
            DataTable expected = null; // TODO: Initialize to an appropriate value
            DataTable actual;
            actual = FileUtility.FileUtility.ReadFileContentToDataTable(filePath, dtTarget, batchId, columnLengthArr);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for ParseDictionary
        ///</summary>
        [TestMethod()]
        public void ParseDictionaryTest()
        {
            string paramString = "[0,Procedure_HPFrocastLogic][1,CSharp_HPFrocastLogic]"; // TODO: Initialize to an appropriate value
          //  Dictionary<string, string> expected = new Dictionary<string,string>(); // TODO: Initialize to an appropriate value
            Dictionary<string, string> actual;
            actual = FileMonitor.Configuration.Utility.ParseDictionary(paramString);
            Assert.AreEqual("Procedure_HPFrocastLogic", actual["0"]);
            Assert.AreEqual("CSharp_HPFrocastLogic", actual["1"]);
          //  Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for ParseNameValueCollection
        ///</summary>
        [TestMethod()]
        public void ParseNameValueCollectionTest()
        {
            string paramString = "[TanesType,'Read'][Plant,AHEH,AHAB,AHAC,AHAE]"; // TODO: Initialize to an appropriate value
            NameValueCollection actual;
            actual = FileMonitor.Configuration.Utility.ParseNameValueCollection(paramString);
            Assert.AreEqual("AHEH,AHAB,AHAC,AHAE", actual[1]);
             
        }



        /// <summary>
        ///A test for GetValueFormConnstring
        ///</summary>
        [TestMethod()]
        public void GetValueFormConnstringTest()
        {
            string connStr = "Database=SAPExchangeDB;Server=10.157.45.88;User Id=sa;Password=Aa000000;"; // TODO: Initialize to an appropriate value
            string key = "User ID"; // TODO: Initialize to an appropriate value
            string expected = "sa"; // TODO: Initialize to an appropriate value
            string actual;
            actual = FileMonitor.Configuration.Tool.Utility.GetValueFormConnstring(connStr, key);
            Assert.AreEqual(expected, actual);
            
        }
    }
}
